<template>
  <div class="dashboard-container">
    <div>
      <el-card class="box-card">
        这是 test 页面
        <div>
          <!-- <img
            src="dev-api/web/image?model=res.partner&id=3&field=image_128&ss=1"
          />
          <img src="dev-api/web/image/357" />
          <img
            src="dev-api/web/image?model=res.partner&id=16&field=image_1920"
          />
          <img
            src="dev-api/web/image?model=res.partner&id=10&field=image_1920"
          />
          <img
            src="dev-api/web/image?model=hr.employee&id=4&field=image_1920"
          /> -->
        </div>
        <div>
          <div v-for="rec in records" :key="rec.id">
            <div v-for="fld in Object.keys(rec)" :key="fld">
              {{ fld }}, {{ rec[fld] }}
            </div>
            <div>--------</div>
          </div>
        </div>

        <!-- {{ userinfo }} -->
      </el-card>
    </div>
  </div>
</template>

<script>
// import odoo from '@/odooapi'
import odoo from '@/odooapi'

export default {
  name: 'Dashboard',
  components: {},
  data() {
    return {
      records: [],
      userinfo: {}
    }
  },
  computed: {},
  async created() {
    this.test()
  },

  mounted() {},
  methods: {
    async test() {
      const model = 'res.partner'
      const Model = odoo.env(model)
      console.log('xxxx, Model: ', Model)

      const res = await Model.search_read({ fields: ['name'] })
      console.log('xxxx, search_read: ', res)

      const res1 = await Model.main_partner()
      console.log('xxxx, main_partner: ', res1)

      const res2 = await Model.search_count({ id___gt: 3 })
      console.log('xxxx, search_count: ', res2)

      const res3 = await Model.env('res.users').search_read({
        fields: ['name']
      })
      console.log('xxxx, env, : ', res3)
    },

    async test3() {
      const model = 'res.partner'
      const Model = odoo.env(model)

      console.log('xxxx, odoo: ', Model)

      const res = await Model.search_read({ fields: ['name'] })
      console.log('xxxx, odoo: ', res)
    },

    async test2() {
      const model = 'res.partner'
      const method = 'search'
      const args = [[]]
      const kwargs = {}

      const res = await odoo.call(model, method, args, kwargs)
      console.log('xxxx, odoo: ', res)
    }
  }
}
</script>
<style></style>
